/**************************************
  IMPEDIMENT
***************************************/

RB.StoryTaskboard = RB.Object.create(RB.Task, {
  
  initialize: function(el){
    var j;  // This ensures that we use a local 'j' variable, not a global one.
    
    this.$ = j = $(el);
    this.el = el;
    
    j.addClass("storytaskboard"); // If node is based on #task_template, it doesn't have the impediment class yet
    
    // Associate this object with the element for later retrieval
    j.data('this', this);
    
    j.find(".editable").live('mouseup', this.handleClick);
  },

//  getID: function(){
//    return this.$.children('.id_placeholder').children('.id').children('.v').text();
//  },
				     
//  editDialogTitle: function(){
//    return "Story #" + this.getID();
//  },

//  getType: function(){
//    return "Story";
//  },

  editDialogTitle: function(){
    return "Edit Story";
  },
				     
  beforeSave: function(){
    // woj: overrides task function to apply color only to top
    var c = this.$.find('select.assigned_to_id').children(':selected').attr('color');
    // woj: can be undefined
    if(!c) {
      c = "";
    }
    this.$.css('border-top', '3px solid ' + c);
  },
				     
  // Override saveDirectives of RB.Task
  saveDirectives: function(){
    var j = this.$;
        
    var url = RB.urlFor( 'update_story', { id: this.getID() } );
    
    var data = '_method=put&taskboard=true&';
    if(j.find('.editor').length > 0) data += "&" + j.find('.editor').serialize();
    
    return {
      url: url,
      data: data
    }
  },

  isNew: function(){
    return false;
  }

});
